import Vue from 'vue'
//引入公共样式和函数
import '@/common/utils/api.js'
import '@/common/utils/style.less'
import '@/assets/font/iconfont.css'
import '@/assets/font/lcdfont.css'
import 'lib-flexible/flexible.js'
//引入具体项目样式和函数
import '@/utils/api.js'
import '@/utils/style.less'
//右键菜单
import contextmenu from '@/common/utils/lib/v-contextmenu.js'
Vue.use(contextmenu)
//md5加密
import md5 from 'js-md5'
Vue.prototype.$md5 = md5
//引入echarts
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
//引入element-ui部分全局
import { Icon, Message, Loading, MessageBox } from 'element-ui'
Vue.use(Icon)
Vue.prototype.$loading = Loading.service
Vue.prototype.$message = Message
Vue.prototype.$confirm = MessageBox.confirm
Vue.prototype.$prompt = MessageBox.prompt
//阻止 vue 在启动时生成生产提示
Vue.config.productionTip = false
//全局未捕获异常
Vue.config.errorHandler = (error, vm, info) => {
  console.log('全局未捕获异常')
  console.error(error)
}

import ehlForm from '@/common/components/form/ehlForm.vue'
export default ehlForm

//只有在懒加载common模块的时候使用
window.$import = async function (module) {
  let cpt = {
    form: [
      'cusInput',
      'ehlAutocomplete',
      'ehlCheckGroup',
      'ehlCode',
      'ehlCron',
      'ehlCronForm',
      'ehlCusTable',
      'ehlDate',
      'ehlEditBox',
      'ehlEditDiv',
      'ehlInput',
      'ehlInputNumber',
      'ehlMenu',
      'ehlMulTable',
      'ehlMulTabs',
      'ehlNavMenu',
      'ehlPage',
      'ehlPdf',
      'ehlRadioGroup',
      'ehlRichEdit',
      'ehlSelect',
      'ehlSelectLazyTree',
      'ehlSelectTree',
      'ehlShuttleBox',
      'ehlStep',
      'ehlTable',
      'ehlTabs',
      'ehlTiling',
      'ehlTree',
      'ehlUpload',
      'ehlYearRange',
    ],
    tool: [
      'ehlBigDataSelect',
      'ehlDialogBox',
      'ehlDragGraph',
      'ehlDragNode',
      'ehlExcel',
      'ehlPopconfirm',
    ],
    graph: ['ehlImage', 'ehlLineBar', 'ehlPie', 'ehlStack'],
  }
  let tmp = null
  if (cpt.form.indexOf(module) > -1) {
    tmp = () => import('@/common/components/form/' + module + '.vue')
  } else if (cpt.tool.indexOf(module) > -1) {
    tmp = () => import('@/common/components/tool/' + module + '.vue')
  } else if (cpt.graph.indexOf(module) > -1) {
    tmp = () => import('@/common/components/graph/' + module + '.vue')
  }
  if (tmp) {
    let re = await tmp()
    return re
  }
  return tmp
}
